clear;close all;
global alpha
alpha_all=[-50,-1,1,50];
h=0.01;
y0=1;x0=0;
x_range=[0 1];

for ii=1:length(alpha_all)
alpha=alpha_all(ii);
[ y{ii},x{ii} ] = RK_ode44( @y_derivation,y0,x0,h,x_range );
y_exact{ii} = y_exact_func( x{ii} );
end

figure;hold on;
% draw marker and line sperately: h is small, and too many sample points
% draw markers with down-sampling
Marker_list={'+','o','^','V'};
for ii=1:length(alpha_all)
hdl=plot(x{ii}(1:10:end),y{ii}(1:10:end),['b' Marker_list{ii}]);
set(hdl,'DisplayName',['R-K Method: alpha = ' num2str(alpha_all(ii))]);
hdl=plot(x{ii}(1:10:end),y_exact{ii}(1:10:end),['r' Marker_list{ii}]);
set(hdl,'DisplayName',['Exact: alpha = ' num2str(alpha_all(ii))]);
end
legend('Show');

% draw lines
for ii=1:length(alpha_all)
plot(x{ii},y{ii},['b-']);
plot(x{ii},y_exact{ii},['r:']);
end
xlim([0 1]);
ylim([0 5]);
xlabel('x');
ylabel('y');
title(['Runge Kutta Methods: h=' num2str(h)]);

figure;hold on;
% draw marker and line sperately: h is small, and too many sample points
% draw markers with down-sampling
Marker_list={'+','o','^','V'};
for ii=1:length(alpha_all)
hdl=plot(x{ii}(1:10:end),abs(y{ii}(1:10:end)-y_exact{ii}(1:10:end)),['b' Marker_list{ii}]);
set(hdl,'DisplayName',['R-K Method error: alpha = ' num2str(alpha_all(ii))]);
end
legend('Show');

% draw lines
for ii=1:length(alpha_all)
plot(x{ii},abs(y{ii}-y_exact{ii}),['b-']);
end
xlim([0 1]);
xlabel('x');
ylabel('y');
title(['Runge Kutta Methods: h=' num2str(h)]);